<template>
  <div>
    <el-form ref="form" :model="form" label-width="120px" class="itemForm">
      <el-form-item label="用户ID">
        <el-input v-model="form.uid" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="find">查询</el-button>
        <el-button type="primary" @click="save">保存</el-button>
        <el-button type="primary" @click="del">删除用户</el-button>
      </el-form-item>

      <el-form-item label="等级">
        <el-input v-model="form.lvl"/>
      </el-form-item>

      <el-form-item label="关卡解锁状态">
        <el-switch v-model="form.openLvl" disabled/>
      </el-form-item>

      <el-form-item label="能量">
        <el-input v-model="form.energy"/>
      </el-form-item>

      <el-form-item label="提示">
        <el-input v-model="form.tipCnt"/>
      </el-form-item>

      <el-form-item label="自适应关卡段位">
        <el-input v-model="form.autoLvlGrade" disabled/>
      </el-form-item>

      <el-form-item label="自适应 当前关卡难度">
        <el-input v-model="form.autoLvlDiff" disabled/>
      </el-form-item>

      <el-form-item label="自适应 当前关卡配置">
        <el-input v-model="form.autoLvlConf" type="textarea" autosize disabled/>
      </el-form-item>

      <el-form-item label="stat">
        <el-input v-model="form.stat" disabled/>
      </el-form-item>

      <el-form-item label="用户名">
        <el-input v-model="form.name" disabled/>
      </el-form-item>

      <el-form-item label="用户openId">
        <el-input v-model="form.openId" disabled/>
      </el-form-item>

      <el-form-item label="用户头像">
        <el-input v-model="form.headImg" disabled/>
      </el-form-item>

      <el-form-item label="邀请上级">
        <el-input v-model="form.inviteUid" disabled/>
      </el-form-item>

    </el-form>
  </div>
</template>

<script>
import { userInfo, updateUser, delAccount } from '@/api/player'

export default {
  name: 'Level',
  data() {
    return {
      form: {
        uid: 0,
        name: '',
        openId: '',
        isAuth: false,
        headImg: '',
        lvl: 0,
        openLvl: false,
        inviteUid: 0,
        energy: 0,
        lastUEnergyT: 0,
        diamond: 0,
        tipCnt: 0,
        autoLvlGrade: 0,
        autoLvlDiff: 0,
        stat: '',
        version: ''
      }
    }
  },
  methods: {

    find() {
      console.log(this.form.uid)
      userInfo({
        uid: this.form.uid
      }).then(response => {
        console.log(response)
        this.form = response.data.player
      })
    },

    save() {
      updateUser({
        uid: this.form.uid,
        level: this.form.lvl,
        energy: this.form.energy,
        tipCnt: this.form.tipCnt,
        diamond: this.form.diamond
      }).then(response => {
        this.$message('保存成功!')
        find()
      })
    },

    del() {
      delAccount({
        uid: this.form.uid
      }).then(response => {
        this.$message('删除成功!')
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.itemForm {
  margin: 30px;
  width: 800px;
}

.allItems {
  width: 800px;
  height: 48px;
}

.items {
  margin: 20px;
}

.item {
  float: left;
  margin: 2px;
}

.item-content {
  display: block;
  width: 16px;
  height: 16px;
}

.none {
  border: 1px solid #ebeef5;
}

.show {
  background-color: burlywood;
}

.hide {
  background-color: burlywood;
}

.text {
  font-size: 14px;
}

.itemIdiom {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}

.box-card {
  margin-left: 30px;
  width: 480px;
}
</style>
